home *** CD-ROM | disk | FTP | other *** search
- unit uOfflineProfile;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ComCtrls, TntComCtrls, IniFiles;
-
- type
- TfrmOfflineProfile = class(TForm)
- Label1: TLabel;
- TntListView1: TTntListView;
- Button1: TButton;
- Button2: TButton;
- procedure TntListView1SelectItem(Sender: TObject; Item: TListItem;
- Selected: Boolean);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- function SelectedProfile: string;
- end;
-
- var
- frmOfflineProfile: TfrmOfflineProfile;
-
- implementation
-
- uses
- Unit1;
-
- {$R *.dfm}
-
- procedure TfrmOfflineProfile.TntListView1SelectItem(Sender: TObject;
- Item: TListItem; Selected: Boolean);
- begin
- Button1.Enabled := Selected;
- Button1.Default := Selected;
- end;
-
- procedure TfrmOfflineProfile.FormCreate(Sender: TObject);
- var
- R: TSearchRec;
- s: string;
- begin
- if FindFirst(ExePath+'data\*.*',faDirectory,R) = 0 then
- try
- repeat
- if (R.Name <> '') and (R.Name[1] <> '.') and
- DirectoryExists(ExePath+'data\'+R.Name+'\dat') then
- with TntListView1.Items.Add do begin
- ImageIndex := 20;
- Caption := R.Name;
- SubItems.Add(R.Name);
- Selected := AnsiCompareText(R.Name,Form1.PhoneIdentity) = 0;
- Focused := Selected;
- try
- with TIniFile.Create(ExePath+'data\'+R.Name+'\dat\Phone.dat') do
- try
- s := ReadString('Global','PhoneName','');
- if s <> '' then Caption := s;
- finally
- Free;
- end;
- except
- end;
- end;
- until FindNext(R) <> 0;
- finally
- FindClose(R);
- end;
- end;
-
- function TfrmOfflineProfile.SelectedProfile: string;
- begin
- if TntListView1.Selected <> nil then
- Result := TntListView1.Selected.SubItems[0]
- else
- Result := '';
- end;
-
- end.
-